﻿using System;

namespace b4
{   public interface methodForShape
    {   //  定义接口，包含算面积和判断合法的抽象函数
        double getArea();
        bool isLegal();
     }
    class Triangle:methodForShape
    {
        public double getArea()
        {//s==1/4sqrt[(a+b+c)(a+b-c)(a+c-b)(b+c-a)]
            return 0.25 * Math.Sqrt((a + b + c) * (a + b - c) * (a + c - b) * (b + c - a));
        }
        public bool isLegal()
        {
            if (a!=0&&b!=0&&c!=0&&a + b > c && a + c > b && b + c > a)
            {//两边之和大于第三边
                return true;
            }
            else
            {
                return false;
            }
        }
        Triangle(double a,double b,double c)
        {
            this.a = a;
            this.b = b;
            this.c = c;
        }
        public void setA(double a)
        {
            this.a = a;
        }
        public void setB(double b)
        {
            this.b = b;
        }
        public void setC(double c)
        {
            this.c = c;
        }
        public double getA()
        {
            return this.a;
        }
        public double getB()
        {
            return this.b;
        }
        public double getC()
        {
            return this.c;
        }
        private double a;
        private double b;
        private double c;
    }
    class Rectangle:methodForShape
    {
        public double getArea()
        {//s==l*w
            return l*w;
        }
        public bool isLegal()
        {
            if (l!=0&&w!=0)
            {
                return true;
            }
            else
            {
                return false;
                
            }
        }
        Rectangle(double l,double w)
        {
            this.l = l;
            this.w = w;
        }
        public void setL(double l)
        {
            this.l = l;
        }
        public void setW(double w)
        {
            this.w = w;
        }
        public double getL()
        {
            return this.l;
        }
        public double getW()
        {
            return this.w;
        }
        private double l;
        private double w;
    }
    class Square:methodForShape
    {
        public double getArea()
        {//s==l*w
            return d*d;
        }
        public bool isLegal()
        {
            if (d!= 0)
            {
                return true;
            }
            else
            {
                return false;

            }
        }
        Square(double d)
        {
            this.d = d;
        }
        public void setD(double d)
        {
            this.d = d;
        }
        public double getD()
        {
            return this.d;
        }
        private double d;
    }
    class Program
    {
        static void Main(string[] args)
        {
            
        }
    }
}
